<template>
  <div class="box">
    <h2>子组件 sub</h2>
    从父组件中获取的值:<label for="">{{$store.state.num}}</label>
    <br>
    <button @click="sub">值-1</button>
    <button @click="test">测试</button>
  </div>
</template>
<style lang="css">
  .box{
    border:1px solid #ccc;
    width:200px;
    padding:5px;
    margin: 20px;
  }
</style>
<script>
import { mapMutations }from 'vuex'
export default {
  name: 'SubItem',
  methods:{
    sub(){
      this.$store.state.num--
    },
    ...mapMutations(['mAdd1','mAddN']),
    test(){
      // this.mAdd1(),
      this.mAddN(10)
    }
  }
}
</script>